package yl.hs.bmipfull.daos.vehiclemanage;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import yl.hs.bmipfull.daos.BaseDao;
import yl.hs.bmipfull.pojo.vehiclemanage.TruckAddFuelRecordEntity;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 作用:  车辆加油记录表持久层接口<br/>
 * 创建时间: 2021年06月17日 10时16分09秒 <br/>
 *
 * @author 张凯
 */
@Repository
public interface ITruckAddFuelRecordDao extends BaseDao<TruckAddFuelRecordEntity> {


    /**
     * 分页查询车辆加油记录表信息
     *
     * @param map 查询条件 {@link TruckAddFuelRecordEntity}
     * @return 站内信息-List<{@link TruckAddFuelRecordEntity}>
     */
    List<TruckAddFuelRecordEntity> queryPage(@Param("map") Map<String, Object> map,@Param("filters") List<Map<String,Object>> filters);

    /**
     * 根据查询条件统计数据数量
     *
     * @param map 查询条件
     * @return 数据数量
     */
    Integer queryCountByCondition(@Param("map") Map<String, Object> map,@Param("filters") List<Map<String,Object>> filters);
    @Select("select * from truck_add_fuel_record where truckplateSn = #{truckplateSn} order by handlerTime desc limit 1")
    TruckAddFuelRecordEntity findByTime(String truckplateSn);

    @Select("update from truck_add_fuel_record set state=#{state} where sn=#{sn} ")
    Integer deleteBySn(int state,String sn);
    @Select("SELECT IFNULL(sum(quantity),0 ) quantity FROM truck_add_fuel_record  where YEAR(handlerTime)=#{year} and MONTH(handlerTime)=#{month} and state>=0 and truckplateSn = #{truckplateSn}")
    BigDecimal GetByYear(int year,int month,String truckplateSn);
    @Select("SELECT IFNULL(sum(quantity),0 ) quantity FROM truck_add_fuel_record  where state>=0 and truckplateSn = #{truckplateSn} ")
    BigDecimal GetByAll(String truckplateSn);
}